package com.kehutong.employee.service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.coraframework.json.JSONObject;

import com.kehutong.employee.entity.Employee;

public class Dep {
	
	public Dep(JSONObject json) {
		this.id = json.getString("id");
		this.name = json.getString("name");
		this.count = 0;
		this.leadIds = new ArrayList<>(4);
		this.leadNames = new ArrayList<>(4);
	}
	
	private String id;
	private String name;
	private int count;
	private List<String> leadIds;
	private List<String> leadNames;
	
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public int getCount() {
		return count;
	}
	
	public void setCount(int count) {
		this.count = count;
	}
	
	public void addCount(int count) {
		this.count += count;
	}
	
	public void adLeader(Employee employee) {
		if (!this.leadIds.contains(employee.getId())) {
			this.leadIds.add(employee.getId());
			this.leadNames.add(employee.getName());
		}
	}
	
	public List<String> getLeadIds() {
		if (leadIds == null) {
			return Collections.emptyList();
		}
		return leadIds;
	}
	
	public void setLeadIds(List<String> leadIds) {
		this.leadIds = leadIds;
	}
	
	public List<String> getLeadNames() {
		if (leadNames == null) {
			return Collections.emptyList();
		}
		return leadNames;
	}
	
	public void setLeadNames(List<String> leadNames) {
		this.leadNames = leadNames;
	}
}